#pragma once
#include "indirect_object.h"
#include "serializer.h"
#include <ostream>

namespace Pdf
{
    class OutputDocument
    {
    public:
		typedef std::ostream::pos_type				PosType;
        typedef std::map<Reference::Value, PosType> RefTable;

		OutputDocument(std::ostream &output);
        ~OutputDocument();

		Dictionary::Ptr			getTrailer();
		void         __fastcall write(const IndirectObject &obj);
		void         __fastcall writeRefTable();
		bool         __fastcall find( const Reference::Value &ref ) const;

    protected:
        std::ostream&			output;
		Dictionary::Ptr			trailer;
        RefTable				reftable;
    };

	// =====================================================================

	inline Dictionary::Ptr OutputDocument::getTrailer()
	{	return trailer;	}

	inline bool OutputDocument::find( const Reference::Value &ref ) const
	{	return reftable.find(ref) != reftable.end();    }
}